package com.sl.au.service.impl;

import java.util.List;

import javax.transaction.Transactional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;

import com.sl.au.entity.Division;
import com.sl.au.entity.DivisionManager;
import com.sl.au.repository.DivisionManagerRepository;
import com.sl.au.service.DivisionManagerService;

@Service
@Transactional
public class DivisionManagerServiceImpl extends BaseServiceImpl implements DivisionManagerService{

	@Autowired
	private DivisionManagerRepository divisionManagerRepository;
	@Override
	public List<DivisionManager> findPageByDivison(Division division, int start, int length) {
		Page<DivisionManager> pages = null;
		Pageable pageable = new PageRequest(start / length, length, Sort.Direction.DESC, "createTime");
		pages = divisionManagerRepository.findByDivision(pageable,division);
		return pages.getContent();
	}
	@Override
	public long fondCountByDivision(Division division) {
		
		return divisionManagerRepository.findCountByDivison(division);
	}
	@Override
	public DivisionManagerRepository getRepository() {
		
		return divisionManagerRepository;
	}

}
